<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<script>
    const arr = [
        {
            "children": [
                {
                    "id": 138,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3863,
                    "itemChildNum": 1,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "252524141",
                    "outerCode": "515321532",
                    "minUnitName": "件",
                    "minUnit": null,
                    "propertiesName": "默认单规格:22*55,",
                    "itemCategoryName": "分类1",
                    "itemChildName": "组合商品--小米手机",
                    "itemChildCode": "P12345688963",
                    "itemSoldPrice": 300,
                    "itemSkuDiyCode": "2525252",
                    "skuCode": "P12345688963001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 1,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 1,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 2,
                    "itemChildCount": 2,
                    "serialNumbers": "MT20220110000001,MT20220110000002,MT20220110000002",
                    "itemChildPrice": 1,
                },
                {
                    "id": 139,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3862,
                    "itemChildNum": 2,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "25252",
                    "outerCode": "525252",
                    "minUnitName": "个",
                    "minUnit": null,
                    "propertiesName": "默认单规格:10*20,",
                    "itemCategoryName": "分类1",
                    "itemChildName": "组合商品--洛基亚",
                    "itemChildCode": "P12345688962",
                    "itemSoldPrice": 200,
                    "itemSkuDiyCode": "2522622",
                    "skuCode": "P12345688962001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 1,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 1,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 4,
                    "itemChildCount": 4,
                    "itemChildPrice": 1,
                    "serialNumbers": "MT20220110000003,MT20220110000004,MT20220110000005,MT20220110000006"
                },
                {
                    "id": 140,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3855,
                    "itemChildNum": 2,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "436452656",
                    "outerCode": "262456456",
                    "minUnitName": "件",
                    "minUnit": null,
                    "propertiesName": "默认单规格:袋装的,",
                    "itemCategoryName": "分类1.2",
                    "itemChildName": "鱿鱼干",
                    "itemChildCode": "P12345688950",
                    "itemSoldPrice": 12300,
                    "itemSkuDiyCode": null,
                    "skuCode": "P12345688950001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 111,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 111,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 444,
                    "itemChildCount": 4,
                    "itemChildPrice": 111,
                    "serialNumbers": "MT20220110000007,MT20220110000008,MT20220110000009,MT20220110000010"
                },
                {
                    "id": 141,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3111,
                    "itemChildNum": 1,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": null,
                    "outerCode": null,
                    "minUnitName": "个",
                    "minUnit": null,
                    "propertiesName": null,
                    "itemCategoryName": "分类1.1",
                    "itemChildName": "6005*90*1000",
                    "itemChildCode": "P12345687768",
                    "itemSoldPrice": 1995000,
                    "itemSkuDiyCode": null,
                    "skuCode": "P12345687768001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 0,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 2,
                    "batchNumber": "",
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 0,
                    "itemChildCount": 2,
                    "itemChildPrice": 0,
                    "serialNumbers": "MT20220110000011,MT20220110000012"
                }
            ],
            "indexNumber": 1,
            "snsNumber": 0,
            "itemCategoryName": "分类1",
            "itemId": 3159,
            "skuId": 3864,
            "decimalInventory": 2,
            "decimalNum": 2,
            "num": 0,
            "inoutPrice": 22500,
            "inoutPriceDec": 225,
            "itemTitle": "洛基亚-小米手机",
            "itemType": 6,
            "skuCode": "P12345688964001",
            "propertiesName": "默认单规格:22*45",
            "minUnitName": "台",
            "imageUrl": "c0d4fb19ec6f49c6a616eae64e00d3b3",
            "soldPrice": 22500,
            "totalPrice": 450,
            "itemCode": "P12345688964",
            "id": 23355,
            "withinCode": "526764u",
            "batchNumber": "",
            "processingCharges": 0,
            "producedDate": null,
            "expiringDate": null,
            "allNum": null,
            "currentFocusInput": "singlePrice"
        }, {
            "children": [
                {
                    "id": 1382,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3863,
                    "itemChildNum": 1,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "252524141",
                    "outerCode": "515321532",
                    "minUnitName": "件",
                    "minUnit": null,
                    "propertiesName": "默认单规格:22*55,",
                    "itemCategoryName": "分类1",
                    "itemChildName": "组合商品--小米手机",
                    "itemChildCode": "P12345688963",
                    "itemSoldPrice": 300,
                    "itemSkuDiyCode": "2525252",
                    "skuCode": "P12345688963001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 1,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 1,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 2,
                    "itemChildCount": 2,
                    "itemChildPrice": 1,
                    "serialNumbers": "MT20220110000001,MT20220110000002"
                },
                {
                    "id": 139,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3862,
                    "itemChildNum": 2,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "25252",
                    "outerCode": "525252",
                    "minUnitName": "个",
                    "minUnit": null,
                    "propertiesName": "默认单规格:10*20,",
                    "itemCategoryName": "分类1",
                    "itemChildName": "组合商品--洛基亚",
                    "itemChildCode": "P12345688962",
                    "itemSoldPrice": 200,
                    "itemSkuDiyCode": "2522622",
                    "skuCode": "P12345688962001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 1,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 1,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 4,
                    "itemChildCount": 4,
                    "itemChildPrice": 1,
                    "serialNumbers": "MT20220110000003,MT20220110000004,MT20220110000005,MT20220110000006"
                },
                {
                    "id": 140,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3855,
                    "itemChildNum": 2,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": "436452656",
                    "outerCode": "262456456",
                    "minUnitName": "件",
                    "minUnit": null,
                    "propertiesName": "默认单规格:袋装的,",
                    "itemCategoryName": "分类1.2",
                    "itemChildName": "鱿鱼干",
                    "itemChildCode": "P12345688950",
                    "itemSoldPrice": 12300,
                    "itemSkuDiyCode": null,
                    "skuCode": "P12345688950001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 111,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 111,
                    "batchNumber": null,
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 444,
                    "itemChildCount": 4,
                    "itemChildPrice": 111,
                    "serialNumbers": "MT20220110000007,MT20220110000008,MT20220110000009,MT20220110000010"
                },
                {
                    "id": 141,
                    "companyId": 1553,
                    "itemId": 3159,
                    "itemChildId": 3111,
                    "itemChildNum": 1,
                    "createdBy": 2797,
                    "createdTime": 1640157178000,
                    "itemType": 1,
                    "withinCode": null,
                    "outerCode": null,
                    "minUnitName": "个",
                    "minUnit": null,
                    "propertiesName": null,
                    "itemCategoryName": "分类1.1",
                    "itemChildName": "6005*90*1000",
                    "itemChildCode": "P12345687768",
                    "itemSoldPrice": 1995000,
                    "itemSkuDiyCode": null,
                    "skuCode": "P12345687768001",
                    "itemGoodsNumber": null,
                    "itemChildStoreName": null,
                    "hasSerialNumber": null,
                    "inoutPriceDec": 0,
                    "orginalImageUrl": null,
                    "decimalInventory": 0,
                    "orderNo": null,
                    "childItem": null,
                    "childsku": null,
                    "outSum": null,
                    "residueNum": null,
                    "outPrice": 2,
                    "batchNumber": "",
                    "parentSkuId": 3864,
                    "itemChildTotalPrice": 0,
                    "itemChildCount": 2,
                    "itemChildPrice": 0,
                    "serialNumbers": "MT20220110000011,MT20220110000012"
                }
            ],
            "indexNumber": 1,
            "snsNumber": 0,
            "itemCategoryName": "分类1",
            "itemId": 3159,
            "skuId": 3864,
            "decimalInventory": 2,
            "decimalNum": 2,
            "num": 0,
            "inoutPrice": 22500,
            "inoutPriceDec": 225,
            "itemTitle": "洛基亚-小米手机",
            "itemType": 6,
            "skuCode": "P12345688964001",
            "propertiesName": "默认单规格:22*45",
            "minUnitName": "台",
            "imageUrl": "c0d4fb19ec6f49c6a616eae64e00d3b3",
            "soldPrice": 22500,
            "totalPrice": 450,
            "itemCode": "P12345688964",
            "id": 23355,
            "withinCode": "526764u",
            "batchNumber": "",
            "processingCharges": 0,
            "producedDate": null,
            "expiringDate": null,
            "allNum": null,
            "currentFocusInput": "singlePrice"
        }
    ]

    // itemChildCount 出库数量
    // '序列号数量需要小于等于出库数量，请重新配置序列号'
    const children = arr.map(item => item.children).flat();
    let checkedResult = true;
    children.find(item => {
        const itemChildCount = item.itemChildCount;
        const serialNumLength = (item.serialNumbers || '').split(',').length;
        if (!(serialNumLength <= itemChildCount)) {
            checkedResult = false;
            return console.log('序列号数量需要小于等于出库数量，请重新配置序列号')
        }
    })
    const serialNumbers = children.map(item => item.serialNumbers).join()
    console.log(checkedResult, serialNumbers);
</script>
</body>
</html>
